package Interface.Requete;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import Metier.Requete.ResultatRequete;

public class InterfaceRequeteResultat extends JFrame{

	private JTable table;
	private JLabel labTextReq;
	private JTextArea  labReq;
	public InterfaceRequeteResultat()
	{
		this.setSize(500, 300);
		this.setLayout(new BorderLayout());
		this.setName("Resultat de la requete");
		this.setTitle("Resultat de la requete");
		this.setVisible(false);
		
	}
	
	public void init()
	{
		if (table!=null)
		this.remove(table);
		if (labReq!=null)
		this.remove(labReq);
	}
	
	public void recharger(ResultatRequete resultat)
	{
		table = new JTable(resultat.getValeur(),resultat.getTitre());
		this.add(table);
		JPanel pan = new JPanel();
		pan.setLayout(new BorderLayout());
		labTextReq = new JLabel("Requete SQL :");
		pan.add(labTextReq,BorderLayout.NORTH);
		labReq = new JTextArea (resultat.getRequete());
		pan.add(labReq);
		this.add(pan,BorderLayout.SOUTH);
		this.setVisible(true);
	}
	
}
